<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>文档列表 - CoCo后台管理系统</title>
<link rel="icon" href="favicon.ico" type="image/ico">
<meta name="author" content="yinqi">
<link href="__STATIC__/admin/css/bootstrap.min.css" rel="stylesheet">
<link href="__STATIC__/admin/css/materialdesignicons.min.css" rel="stylesheet">
<link href="__STATIC__/admin/css/style.min.css" rel="stylesheet">
</head>
  
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    
    <!--左侧导航-->
    {include file="../application/admin/view/common/left.html"}
    <!--End 左侧导航-->
    
    <!--头部信息-->
    {include file="../application/admin/view/common/header.html"}
    <!--End 头部信息-->
    
    <!--页面主要内容-->
    <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-toolbar clearfix">
                <div class="toolbar-btn-action">
                  <a class="btn btn-primary m-r-5" href="/admin/admin/add_admin"><i class="mdi mdi-plus"></i> 管理员新增</a>
                </div>
              </div>
              <div class="card-body">
                
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                      <tr>
                        <th>
                          <label class="lyear-checkbox checkbox-primary">
                            <input type="checkbox" id="check-all"><span></span>
                          </label>
                        </th>
                        <th>ID</th>
                        <th>管理员名称</th>
                        <th>管理员账号</th>
                        <th>管理员头像</th>
                        <th>注册时间</th>
                        <th>权限</th>
                        <th>超级管理员</th>
                        <th>操作</th>
                      </tr>
                    </thead>
                    <tbody>
                      {volist name="ret" id="r1"}
                      <tr>
                        <td>
                          <label class="lyear-checkbox checkbox-primary">
                            <input type="checkbox" name="ids[]" value="1"><span></span>
                          </label>
                        </td>
                        <td>{$r1.admin_id}</td>
                        <td>{$r1.admin_name}</td>
                        <td>{$r1.admin_account}</td>
                        <td><img src="{$r1.admin_himg}" style="width: 80px;height: 80px"></td>
                        <td>{$r1.admin_addtime|date="Y-m-d H:i:s",###}</td>
                        {if condition="$r1.admin_power eq 1"}
                          <td><a class="btn btn-success m-r-5" onclick="admin_modify_power('{$r1.admin_id}',0);"><i class="mdi mdi-check"></i> 启用</a></td>
                        {else/}
                          <td><a class="btn btn-warning m-r-5" onclick="admin_modify_power('{$r1.admin_id}',1);"><i class="mdi mdi-block-helper"></i> 禁用</a></td>
                        {/if}
                        {if condition="$r1.admin_super eq 1"}
                          <td><a class="btn btn-success m-r-5" onclick="admin_modify_super('{$r1.admin_id}',0);"><i class="mdi mdi-check"></i> 启用</a></td>
                        {else/}
                          <td><a class="btn btn-warning m-r-5" onclick="admin_modify_super('{$r1.admin_id}',1);"><i class="mdi mdi-block-helper"></i> 禁用</a></td>
                        {/if}
                        <td>
                          <div class="btn-group"> 
                            <a class="btn btn-xs btn-default" href="/admin/admin/modify_admin?admin_id={$r1.admin_id}" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                            <a class="btn btn-xs btn-default" onclick="admin_del('{$r1.admin_id}');" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
                          </div>
                        </td>
                      </tr>
                      {/volist}
                    </tbody>
                  </table>
                </div>
                {$pageHtml}
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<script type="text/javascript" src="__STATIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/main.min.js"></script>
<script>
layui.use('layer', function(){
    var layer = layui.layer;
  });

function admin_del(admin_id){
  layer.confirm('确定删除该管理员吗?', {icon: 3}, function(index){
      $.ajax({
          url:'/admin/admin/admin_del',
          type:'get',
          dataType:'json',
          data:{admin_id:admin_id},
          success:function(data){
            if(data.status==0){
              layer.msg(data.msg,{icon: 5,time:2000,success:function(){window.location.reload();}});
            }else{
              layer.msg(data.msg,{icon: 6,time:2000,success:function(){window.location.reload();}});
            }
          }
        });
      layer.close(index);
    });
}
  
function admin_modify_power(admin_id,status){
    if(status==1){
      url = '/admin/admin/admin_pass';
    }else{
      url = '/admin/admin/admin_fail';
    }
    $.ajax({
        url:url,
        type:'get',
        dataType:'json',
        data:{admin_id:admin_id},
        success:function(data){
          if(data.status==0){
            layer.msg(data.msg,{icon: 5,time:2000,success:function(){
              setTimeout(function(){window.location.reload();},1000);
            }});
          }else{
            layer.msg(data.msg,{icon: 6,time:2000,success:function(){
              setTimeout(function(){window.location.reload();},1000);
            }});
          }
        }
      });
  }

function admin_modify_super(admin_id,status){
    if(status==1){
      url = '/admin/admin/admin_super_pass';
    }else{
      url = '/admin/admin/admin_super_fail';
    }
    $.ajax({
        url:url,
        type:'get',
        dataType:'json',
        data:{admin_id:admin_id},
        success:function(data){
          if(data.status==0){
            layer.msg(data.msg,{icon: 5,time:2000,success:function(){
              setTimeout(function(){window.location.reload();},1000);
            }});
          }else{
            layer.msg(data.msg,{icon: 6,time:2000,success:function(){
              setTimeout(function(){window.location.reload();},1000);
            }});
          }
        }
      });
  }
</script>
<script type="text/javascript">
$(function(){
    $('.search-bar .dropdown-menu a').click(function() {
        var field = $(this).data('field') || '';
        $('#search-field').val(field);
        $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
    });
});
</script>
</body>
</html>